<template>
  <div class="subscribe">
    <!--S表单-->
    <el-form
      ref="settingForm"
      class="setting-form"
      :rules="formDataRules"
      :model="formData"
      label-position="top"
      label-width="100px"
      style="width: 500px;"
    >
      <el-alert
        :closable="false"
        title="请在公众号内请先设置服务类目为：IT科技>软件服务提供商"
        type="success">
      </el-alert>
      <el-form-item label="订阅消息-审核结果通知模板id" prop="result_check_sub">
        <el-input v-model="formData.result_check_sub" placeholder="订阅消息-审核结果通知模板id" />
      </el-form-item>
      <el-button type="primary" size="small" @click="submit">一键配置</el-button>
    </el-form>
    <!--E表单-->
  </div>
</template>

<script>
export default {
  name: 'Subscribe',
  props: {
    setting: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      formData: {
        result_check_sub: ''
      },
      formDataRules: {
        result_check_sub: [
          { required: true, message: '不能为空', trigger: 'blur' }
        ]
      }
    }
  },
  watch: {
    setting() {
      const { result_check_sub } = this.setting
      this.formData = {
        result_check_sub
      }
    }
  },
  methods: {
    submit() {
      this.$post('setting/message/autoSetSubscribeMessage')
        .then((res) => {
          this.formData.result_check_sub = res.data.data.result_check_sub
          this.$message.success('配置成功')
        })
    }
  }
}
</script>
